#include "../include/observer.h"
#include "../include/publisher.h"
#include <iostream>
#include <memory>

using namespace std;

void publisher::addSubscriber(string name, unique_ptr<observer> ob)
{
    this->observers[name] = std::move(ob);
}

void publisher::deleteSubscriber(string name)
{
    this->observers.erase(name);
}

void publisher::notify()
{
    unordered_map<string, unique_ptr<observer>>::iterator iter;
    for (iter = observers.begin(); iter != observers.end(); iter++) {
        iter->second->update();
    }
}
